#include <iostream>

using std::cout;
using std::endl;

class Point {
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    , _z(_ix)  //引用成员必须要放在初始化列表中进行，否则编译时报错
              //ix是构造函数的形参，其生命周期会在构造函数调用结束时销毁
    {
        //_ix = ix;//error,赋值操作
        //_iy = iy;
        _z = _ix;//赋值操作
    }

    void print() 
    {
        cout << "(" << _ix 
             << "," << _iy
             << "," << _z
             << ")" << endl;
    }


private:
    int _ix;
    int _iy;
    int & _z;//引用的底层实现还是指针，依然占据一个指针的大小
};

int main()
{
    cout << "sizeof(Point):" << sizeof(Point) << endl;
    Point pt(10, 11);
    cout << "pt:";
    pt.print();

    Point pt2;
    cout << "pt2:";
    pt2.print();
    

    return 0;
}

